﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPages/Core.Master"
    CodeBehind="UnionDepositAssociation.aspx.cs" Inherits="Pap.Web.Modules.Loan.Views.UnionDepositAssociation"
    meta:resourcekey="PageResource1" %>

<%@ Register Src="../../Shared/Views/InsertAttchments.ascx" TagName="InsertAttchments"
    TagPrefix="uc1" %>
<asp:Content runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
    <script type="text/javascript">

        var TxtDepositChanged = function (currentInt, newValue, oldValue) {
            var BalanceAfterCtrl = Ext.getCmp('txtBalanceAfterDeposit');
            var BalanceBefore = Ext.getCmp('txtBalanceBeforeDeposit').value;
            BalanceAfterCtrl.setValue(BalanceBefore - newValue);
        }
    
    </script>
    <ext:Store runat="server" ID="storeAssociations" AutoLoad="True" IDMode="Legacy"
        meta:resourcekey="storeAssociationsResource1" SerializationMode="Simple">
        <Reader>
            <ext:JsonReader ReaderID="CommitteeID">
                <Fields>
                    <ext:RecordField Name="CommitteeID" />
                    <ext:RecordField Name="CommitteeName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <SortInfo Direction="ASC"></SortInfo>
    </ext:Store>
    <ext:Store runat="server" ID="storeProjects" AutoLoad="True" IDMode="Legacy" meta:resourcekey="storeProjectsResource1"
        SerializationMode="Simple">
        <Reader>
            <ext:JsonReader ReaderID="ProjectID">
                <Fields>
                    <ext:RecordField Name="ProjectID" />
                    <ext:RecordField Name="ProjectName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <SortInfo Direction="ASC"></SortInfo>
    </ext:Store>
    <ext:Store runat="server" ID="storeAssociationDeposits" AutoLoad="True" IDMode="Legacy"
        meta:resourcekey="storeAssociationDepositsResource1" SerializationMode="Simple">
        <Reader>
            <ext:JsonReader>
                <Fields>
                    <ext:RecordField Name="DepositDate" Type="Date" />
                    <ext:RecordField Name="DepositAmount" />
                    <ext:RecordField Name="OperationNumber" />
                    <ext:RecordField Name="ProjectName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <SortInfo Direction="ASC"></SortInfo>
    </ext:Store>
    <ext:FitLayout runat="server">
        <ext:Panel runat="server" Title="<%$Resources:grvAssociationDepositsTitle %>">
            <Body>
                <ext:FitLayout runat="server">
                    <ext:GridPanel runat="server" ID="grvAssociationDeposits" StoreID="storeAssociationDeposits" 
                    AutoExpandColumn="ProjectName" StripeRows="true" Frame="true">
                        <TopBar>
                            <ext:Toolbar runat="server">
                                <Items>
                                    <ext:ComboBox ValueField="CommitteeID" FieldLabel="Committee" DisplayField="CommitteeName"
                                        runat="server" ID="cmbAssociations" StoreID="storeAssociations" Editable="false"
                                        AllowBlank="false" meta:resourcekey="cmbAssociationsResource">
                                        <AjaxEvents>
                                            <Select OnEvent="cmbAssociations_Selected">
                                                <EventMask CustomTarget="grvAssociationDeposits" ShowMask="true" />
                                            </Select>
                                        </AjaxEvents>
                                    </ext:ComboBox>
                                    <ext:ToolbarSeparator runat="server">
                                    </ext:ToolbarSeparator>
                                    <ext:ToolbarButton ID="uxNewDepositButton" runat="server" Icon="MoneyAdd" meta:resourcekey="btnNewDeposit">
                                        <AjaxEvents>
                                            <Click OnEvent="btnNewDeposit_Click">
                                            </Click>
                                        </AjaxEvents>
                                    </ext:ToolbarButton>
                                </Items>
                            </ext:Toolbar>
                        </TopBar>
                        <ColumnModel>
                            <Columns>
                                <ext:Column DataIndex="DepositDate" Header="<%$Resources:DepositDate %>" Sortable="True">
                                    <Renderer Fn="Ext.util.Format.dateRenderer('d/m/Y')" />
                                </ext:Column>
                                <ext:Column DataIndex="ProjectName" Header="<%$Resources:ProjectName %>" Sortable="True" />
                                <ext:Column DataIndex="DepositAmount" Header="<%$Resources:DepositAmount %>" Sortable="True" />
                                <ext:Column DataIndex="OperationNumber" Header="<%$Resources:OperationNumber %>"
                                    Sortable="True" />
                            </Columns>
                        </ColumnModel>
                        <BottomBar>
                            <ext:PagingToolbar ID="pagingBar" runat="server" StoreID="storeAssociationDeposits"
                                PageSize="15" DisplayInfo="True" IDMode="Static" meta:resourcekey="pagingBarResource1">
                            </ext:PagingToolbar>
                        </BottomBar>
                        <SelectionModel>
                            <ext:RowSelectionModel runat="server"></ext:RowSelectionModel>
                        </SelectionModel>
                    </ext:GridPanel>
                </ext:FitLayout>
            </Body>
            <BottomBar>
                <ext:StatusBar runat="server">
                    <Items>
                        <ext:Button runat="server" IDMode="Static" ID="btnBack" Text="<%$ Resources:BackButton %>"
                            Icon="ArrowUndo">
                            <AjaxEvents>
                                <Click OnEvent="btnBack_Clicked" />
                            </AjaxEvents>
                        </ext:Button>
                    </Items>
                </ext:StatusBar>
            </BottomBar>
        </ext:Panel>
    </ext:FitLayout>
    <ext:Window runat="server" ID="uxNewDepositWindow" Modal="true" ShowOnLoad="false"
        Frame="true" Title='<%$ Resources:btnNewDeposit.Text %>' AutoHeight="true" Width="600px"
        Collapsible="false" Closable="false" CloseAction="Close" AutoScroll="true">
        <Body>
            <ext:FormPanel ID="panelDeposit" runat="server" Frame="true" Border="true">
                <Body>
                    <ext:FormLayout runat="server">
                        <ext:Anchor Horizontal="95%">
                            <ext:ComboBox ValueField="ProjectID" DisplayField="ProjectName" runat="server" ID="cmbProjects"
                                meta:resourcekey="cmbProjectsResource" StoreID="storeProjects" Editable="false"
                                AllowBlank="false" />
                        </ext:Anchor>
                        <ext:Anchor Horizontal="95%">
                            <ext:TextField runat="server" FieldLabel="Balance Before Deposit" IDMode="Static"
                                ID="txtBalanceBeforeDeposit" meta:resourcekey="txtBalanceBeforeDepositResource"
                                Disabled="true" />
                        </ext:Anchor>
                        <ext:Anchor Horizontal="95%">
                            <ext:TextField runat="server" FieldLabel="Balance After Deposit" ID="txtBalanceAfterDeposit"
                                Disabled="true" IDMode="Static" meta:resourcekey="txtBalanceAfterDepositResource" />
                        </ext:Anchor>
                        <ext:Anchor Horizontal="95%">
                            <ext:DateField runat="server" ID="dtDepositeDate" AllowBlank="false" meta:resourcekey="txtDepositDateResource" />
                        </ext:Anchor>
                        <ext:Anchor Horizontal="95%">
                            <ext:TextField runat="server" meta:resourcekey="txtOperationNumberResource" FieldLabel="Operation Number"
                                ID="txtOperationNumber" AllowNegative="false" AllowBlank="false" Regex="^[0-9]+$"
                                MaxLength="50">
                            </ext:TextField>
                        </ext:Anchor>
                        <ext:Anchor Horizontal="95%">
                            <ext:NumberField runat="server" meta:resourcekey="txtDepositAmountResource" FieldLabel="Deposit Amount"
                                ID="txtDepositAmount" AllowNegative="false" MaxValue="1" MinValue="1" AllowBlank="false"
                                MaxLength="28">
                                <Listeners>
                                    <Change Fn="TxtDepositChanged" />
                                </Listeners>
                            </ext:NumberField>
                        </ext:Anchor>
                        <ext:Anchor Horizontal="95%">
                            <ext:Panel ID="Panel1" runat="server" Title="Attachments" Collapsible="true" CollapseFirst="true">
                                <Body>
                                    <uc1:InsertAttchments ID="InsertAttchments1" runat="server" ViewMode="Edit" />
                                </Body>
                            </ext:Panel>
                        </ext:Anchor>
                    </ext:FormLayout>
                </Body>
            </ext:FormPanel>
        </Body>
        <BottomBar>
            <ext:StatusBar ID="StatusBar1" runat="server">
                <Plugins>
                    <ext:ValidationStatus r unat="server" FormPanelID="panelDeposit" ValidIcon="Accept"
                        ErrorIcon="Exclamation" meta:resourcekey="wndpnlValidationResource1">
                    </ext:ValidationStatus>
                </Plugins>
                <Items>
                    <ext:Button runat="server" ID="btnCancel" Icon="Cancel" Text='<%$ Resources:BackButton %>'>
                        <AjaxEvents>
                            <Click OnEvent="btnCancel_Click">
                                <EventMask ShowMask="true" />
                            </Click>
                        </AjaxEvents>
                    </ext:Button>
                    <ext:Button runat="server" ID="btnDeposit" meta:resourcekey="cmbAssociationsResource"
                        Icon="MoneyAdd" Text="Deposit">
                        <AjaxEvents>
                            <Click OnEvent="BtnDeposit_Clicked" Before="return #{panelDeposit}.getForm().isValid();">
                                <EventMask ShowMask="true" />
                            </Click>
                        </AjaxEvents>
                    </ext:Button>
                </Items>
            </ext:StatusBar>
        </BottomBar>
    </ext:Window>
</asp:Content>
